import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      // 首页
      { path: '/', component: () => import('@/views/Home') },
      // 商品详情
      { path: '/goods/:id', component: () => import('@/views/Goods') },
      // 分类
      { path: '/category/:id', component: () => import('@/views/Category') }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  }
]

// Vue2 => new VueRouter()
// Vue3 => createRouter
const router = createRouter({
  // 使用 Hash 模式的路由
  history: createWebHashHistory(),
  routes
})

export default router
